#!/bin/bash

factorial=$[ $1 * $2 ]
for (( number = 10; number <= 10; number++ ))
do
	factorial=$[ $factorial * $number ]
done
echo The factorial is $factorial

echo ${12}

echo $0

echo "第三个参数是 $3"

#name=$(basename $0)
#if [ $name = "addem" ]
#then
#	total=$[ $1 + $2 ]
#elif [ $name = "multem" ]
#then
#	total=$[ $1 * $2 ]
#fi
#echo "total is $total"


#cp demo.sh addem
#chmod u+x addem

#ln -s demo.sh multem

#ls -l *em

if [ -n "$3" ]
then
	echo "is $3"
else
	echo 'no $3'
fi

echo "total is $#"

if [ $# -ne 3 ]
then
	echo "$0 params total is $#"
else
	total=$[ $1 + $2 ]
	echo "$0 params is 1 : $1 , 2 : $2, total is $total"
fi

echo "the last params is ${!#}"

count=1
for param in "$*"
do
	echo "\$* parameter #$count = $param"
	count=$[ $count + 1 ]
done

count=1
for param in "$@"
do
	echo "\$@ parameter #count = $param"
	count=$[ $count + 1 ]
done
#count=1
#while [ -n "$1" ]
#do
#	echo "parameter #$count = $1"
#	count=$[ $count + 1 ]
#	shift
#done

while [ -n "$1" ]
do
	echo "is ok"
	case "$1" in 
		12) echo "\$1 is $1" ;;
		2) echo "\$1 is $1" ;;
		*) echo "\$1 is not have" ;;
	esac
	shift
done
while [ -n "$1" ]
do
	case "$1" in 
		1) echo "$1";;
		3) echo "$1" ;;
		--) ;;
		*) echo no;;
	esac
	shift
done


